<?php

class MyjobController extends Controller
{
    public function filters()
    {
                return array(
                        'accessControl', // perform access control for CRUD operations
                );
    }
   public function accessRules()
    {
        return array(
            array('allow', // allow authenticated user to perform 'create' and 'update' actions
                'actions'=>array('index','view','quality'),
                'users'=>array('@'),
            ),
            array('allow', // allow admin user to perform 'admin' and 'delete' actions
                'actions'=>array('admin','delete'),
                'users'=>array('admin'),
            ),
            array('deny',  // deny all users
                'users'=>array('*'),
            ),
        );
    }
    public function actionIndex()
    {
        $this->render('index');   
    }
    public function actionQuality($value)
    {
        $criteria = new CDbCriteria;
        $criteria->limit = $value;
        $criteria->condition = "user_id=".Yii::app()->user->id;
        $data = Job::model()->findAll($criteria);
        $this->renderPartial('_quality',array('data'=>$data));  
    }
    public function actionSearch()
    {
        if (isset($_POST["input_search"])) {
            $str = $_POST["input_search"];
            $criteria = new CDbCriteria;
            $criteria->condition = "name like '%$str%' and "."user_id=".Yii::app()->user->id;
            $data = Job::model()->findAll($criteria);
            $this->renderPartial('_quality',array('data'=>$data));  
        }
    }
}
?>